﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Text;

public partial class wiki : System.Web.UI.Page
{
    List<abItem> abArray = ab.GetAbArrayList();
    protected String cpageName = String.Empty;
    protected String cDescription = String.Empty;
    protected String cTitle = String.Empty;
    protected Int32 catid = 0;

    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            CategoryItem arr = Category.ItemById(5);
            if (arr != null)
            {
                cTitle = arr.cTitle;
                catid = arr.catId;
                cDescription = arr.cDescription;
            }
        }
        catch { }

        HtmlMeta meta = new HtmlMeta();
        meta.Name = "keywords";
        meta.Content = PageHeaderData.GetPageKeywordsByType(NewsType.Wiki);
        this.Header.Controls.Add(meta);
    }

    public string SetAbList
    {
        get
        {
            StringBuilder strLinks = new StringBuilder();
            StringBuilder divWiki = new StringBuilder();

            if (abArray != null)
            {
                strLinks.Append(@"<ul class=""menuabc"">");
                for (int iCount = 0; iCount < 27; iCount++)
                {
                    abItem itemAB = abArray[iCount];
                    string sText = string.Format("<li><a href=\"#tab{0}\"><span>{1}</span></a></li>", itemAB.abValue, itemAB.abText.ToUpper());
                    strLinks.Append(sText);
                    //strCategorys.
                }
                strLinks.Append("</ul>");
            }
            return strLinks.ToString();
        }
    }

    public string SetItemsList
    {
        get
        {
            StringBuilder strLinks = new StringBuilder();
            List<CategoryItem> CatList = Category.ByAncestors((int)NewsType.Wiki);
            List<CategoryItem> filteredList;
            if (CatList != null)
            {
                for (int iCount = 0; iCount < 27; iCount++)
                {
                    abItem ItemAB = abArray[iCount];
                    strLinks.Append("<div class=\"wiki1N\"  id=\"tab" + ItemAB.abValue + "\">");
                    //                'a href to wikiA
                    filteredList = CatList.FindAll(new HandFinderKeysbyId(ItemAB.abText).Match);
                    if (filteredList != null)
                    {
                        List<CategoryItem> subCategorys = null;

                        foreach (CategoryItem f in filteredList)
                        {
                            string sText = string.Format("<a href=\"{0}-w.aspx\">{1}</a>", HttpUtility.UrlEncode(f.cPageName), f.cTitle);
                            strLinks.Append(sText);
                            subCategorys = Category.ByAncestors(f.catId);
                            if (subCategorys != null)
                            {
                                if (subCategorys.Count > 0)
                                {
                                    strLinks.Append("<ul>");
                                    foreach (CategoryItem subc in subCategorys)
                                    {
                                        sText = string.Format("<li><a href=\"{0}-w.aspx\">{1}</a></li>", HttpUtility.UrlEncode(subc.cPageName), subc.cTitle);
                                        strLinks.Append(sText);
                                    }
                                    strLinks.Append("</ul>");
                                }
                            }
                        }
                    }
                    strLinks.Append("</div>");

                }
                //            'End of  div class=""wikiN""
                //strLinks.Append("</div>");
            }
            return strLinks.ToString();

        }
    }

    
    
}
